﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02public
{
    class Program
    {
        public class StructStudent
        {
            private string _Name;
            private string _Sex;
           private int _Age;
           private string _Addr;
       
            public string Name{
                get{return _Name;}
                set{_Name=value;}
            }

            public string Sex{
                get{return _Sex;}
                set{
                    if(value !="男"&&value!="女"){
                        Console.WriteLine("Sex属性只能赋值【男】或者【女】");
                        _Sex ="男";
                    }else{
                        _Sex=value;
                    }

                }
            }
            public int Age{
                get{return _Age;}
                set{
                    if(value<18||value>38){
                         Console.WriteLine("Age属性只能赋值18~38");
                        _Age = 0;
                    }else{
                        _Age=value;
                    }
                }
            }
            public string Addr{
                get{return _Addr;}
                set{ _Addr = value;}
            }
        
            public void Show()
            {
                Console.WriteLine("Show()方法显示内容-->Name:{0},Sex:{1},Age:{2},Addr:{3}",_Name,_Sex,_Age,_Addr);
            }
            public StructStudent(string name, string sex, int age, string addr)
            {
                this._Name =name;
                _Sex = sex;
                _Age = age;
                _Addr = addr;
            }
            public StructStudent()
            {

            }
       
        }
        static void Main(string[] args)//栈
        {
            StructStudent stu = new StructStudent();
            stu.Name = "冷榷";
            stu.Sex = "男";
            stu.Age = 22;
            stu.Addr = "冷之若霜，商之常榷";
            stu.Show();

            Console.WriteLine("main中Show()方法显示内容-->Name:{0},Sex:{1},Age:{2},Addr:{3}", stu.Name, stu.Sex, stu.Age, stu.Addr);


            StructStudent stu2 = new StructStudent("杰落心痕", "女", 18, "心若有痕何时平");
            stu2.Show();
            Console.WriteLine("stu2Show()方法显示内容-->Name:{0},Sex:{1},Age:{2},Addr:{3}", stu2.Name, stu2.Sex, stu2.Age, stu2.Addr);

            Console.ReadKey();
        }
    }
}
